home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-serious-
/
programming
/
c
/
icu-1.3.1
/
icuapps
/
locexp
/
tools
/
escapeforbundle.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-02-23
|
824b
|
44 lines
/* (c) 1999 IBM, Inc.
This little program takes utf16_be input and outputs
escaped text suitable for inclusion in a resource bundle.
Use it like this:
uconv -f <srccodepage> -t utf16_be | escapeForBundle >> myResource.txt
*/
#include <stdio.h>
#include <ctype.h>
typedef unsigned short UChar;
int main()
{
UChar myChar;
char cHi, cLo;
while(!feof(stdin))
{
cHi = getchar();
if(feof(stdin)) return; /* half-char */
cLo = getchar();
myChar = (cHi<<8) | cLo;
if( (cHi == 0) && /* high byte UNset */
isprint(cLo) && /* considered printable */
(cLo != '"') && /* Not our two special chars: " and */
(cLo != '\\') ) /* \ */
{
putchar(cLo);
}
else
{
printf("\\u%04X", (int) myChar);
}
}
}